package member.controller;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import member.model.service.MemberService;
import member.to.ActionForward;
import member.to.MemberTO;

public class SearchMemberByNameController implements Controller {

	@Override
	public ActionForward handle(HttpServletRequest request, HttpServletResponse response){
		ActionForward af = null;
		//1. 요청파라미터 조회
		String name = request.getParameter("name");
		//2. B.L 처리
		MemberService mms = MemberService.getInstance();
		try{
			ArrayList<MemberTO> list = mms.searchMemberByName(name);
			request.setAttribute("member_list", list);
			request.setAttribute("title", "이름으로 검색");
			request.setAttribute("search_value", name);
			af = new ActionForward("/member_list.jsp", false);			
		}catch(SQLException sqle){
			sqle.printStackTrace();
			request.setAttribute("error_message", "이름으로 검색도중 오류발생");
			af = new ActionForward("/error.jsp", false);
		}	
		return af;
	}

}













